<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>倒计时</title>
</head>

<body>
  <script>
    "use strict";
    const countDown = (time) => {
      const nowTime = +new Date(); //返回当前时间的总毫秒数
      const inputTime = +new Date(time); //返回的是用户输入的时间毫秒数
      const times = (inputTime - nowTime) / 1000; //times是剩余时间总的秒数
      const d = parseInt(times / 60 / 60 / 24); //天
      /* // str.padEnd
      const h = parseInt(times / 60 / 60 % 24); //时
      const m = parseInt(times / 60 % 60); //分
      const s = parseInt(times % 60); //当前的秒 */
      // return `${d}天${h}时${m}分${s}秒`;
      console.log(d);
    };
    countDown("2019-5-1 18:00:00");
  </script>
</body>

</html>